package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.CollectDao;
import com.delivery.www.dao.DaoImpl.CollectDaoImpl;
import com.delivery.www.po.Collect;
import com.delivery.www.service.CollectService;

import java.util.List;

/**
 * @author 12970
 */
public class CollectServiceImpl implements CollectService {
    private final CollectDao collectDao = new CollectDaoImpl();

    @Override
    public boolean doCollect(int userId, int dishId) {
        if (userId > 0 && dishId > 0) {
            return collectDao.doCollect(userId, dishId) > 0;
        } else {
            return false;
        }
    }

    @Override
    public List<Collect> getCollect(int userId) {
        if (userId > 0) {
            return collectDao.getCollect(userId);
        } else {
            return null;
        }
    }

    @Override
    public boolean cancelCollect(int userId, int dishId) {
        if (userId > 0 && dishId > 0) {
            return collectDao.cancelCollect(userId, dishId) > 0;
        } else {
            return false;
        }
    }

    @Override
    public Collect getOneCollect(int userId, int dishId) {
        if (userId > 0 && dishId > 0) {
            return collectDao.getOneCollect(userId, dishId);
        } else {
            return null;
        }
    }
}
